/**
 * Created by yu on 16/8/21.
 */

var fs = require('fs');
//缺点
//1.不利于阅读
//2.可以同时做的,浪费时间

fs.readFile('./name.txt','utf8',function(err,name){
    fs.readFile('./age.txt','utf8',function(err,age){
        console.log(name,age);
    })
})
//计数器方式
var person = {};
function show(){
    if(Object.keys(person).length==2){
        console.log(person);
    }
}
fs.readFile('./age.txt','utf8',function(err,age){
    person.age = age;
    show();
})
fs.readFile('./name.txt','utf8',function(err,name){
    person.name = name;
    show();
})

//promise实现

